from lib.base import Base
class RenameTable(Base):

    db = None
    query = None
    table = ""
    column_name = ""

    def __init__(self, db, query):
        self.db = db
        self.query = self._determine_attributes(query)

    def execute(self):
        if self.query == None:
            print "Database does not support this operation"
        else:
            print "Running renaming table: %s, to: %s" % (self.table, self.new_name)
            self.db.execute(self.query)
        return True

    def _determine_attributes(self, query):
        query = self._trim_table(query)
        query = self._trim_new_name(query)
        return self.db.format_rename_table(self.table, self.new_name)